var EventEmitter = require('events').EventEmitter;//class
var mixin = require('merge-descriptors');
var req=require('./request');
var res=require('./response');
var application=require('./application');
//exports 和modul.exports 默认指向同一个空对象
exports=module.exports=function  (){
    function app(req, res, next){
        app.handle(req,res,next);
    }
    Object.keys(EventEmitter.prototype).forEach(function(i){
        app[i]=EventEmitter.prototype[i]
    });
    Object.keys(application).forEach(function(i){
        app[i]=application[i]
    });
    //create req是创建对象的原型,参数二是对象的属性
    app.request=Object.create(req,{
        app:{
            configurable:true,enumerable:true,writable:true,value:app
        }
    })
    // console.log(Object.keys(req),Object.keys(app.request))
    app.response=Object.create(res,{
        app:{
            configurable:true,enumerable:true,writable:true,value:app
        }
    })
    app.init();
    return app;
};
//在函数上添加静态方法，require('').xx来访问
exports.application=application;


